package com.tuanzi.loan.web.bean.credithousekeeper;

import com.tuanzi.loan.business.service.credithousekeeper.CreditCompensatoryChildOrderStatService;
import com.tuanzi.loan.vo.request.credithousekeeper.CreditCompensatoryChildOrderStatRequest;
import com.tuanzi.loan.vo.response.credithousekeeper.CreditCompensatoryChildOrderStatResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.credithousekeeper.CreditCompensatoryChildOrderStatLazyDataModel;
import com.tuanzi.server.loan_base.constant.CardCompensationOrderStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;

/**
 * @Description:    信用卡代偿子订单统计后台bean
 * @Author:         xionghao
 * @CreateDate:     2018-08-17
 */
@Data
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class CreditCompensatoryChildOrderStatListBean
        extends JSFListingBean<CreditCompensatoryChildOrderStatRequest,CreditCompensatoryChildOrderStatResponse> {

    @Autowired
    private CreditCompensatoryChildOrderStatService creditCompensatoryChildOrderStatService;
    @PostConstruct
    public void init(){
        initLazyDataModel();
    }

    private void  initLazyDataModel(){
        $ = new CreditCompensatoryChildOrderStatRequest();
        lazyDataModel = new CreditCompensatoryChildOrderStatLazyDataModel($);
    }
    //订单状态：待确认、处理中、成功、失败、中止、异常
    public String traslationOrderStatus(String status){
        if(status!=null||!"".equals(status)){
            Integer statuss = Integer.parseInt(status);
            switch (statuss){
                case CardCompensationOrderStatus.ALLIN_TO_BE_CONFIRM:
                    return "待确认";
                case CardCompensationOrderStatus.ALLIN_PROCESSING:
                    return "处理中";
                case CardCompensationOrderStatus.ALLIN_SUCCESS:
                    return "成功";
                case CardCompensationOrderStatus.ALLIN_FAIL:
                    return "失败";
                case CardCompensationOrderStatus.ALLIN_PAUSE:
                    return "中止";
                case CardCompensationOrderStatus.ALLIN_EXCEPTION:
                    return "异常";
                case CardCompensationOrderStatus.INIT:
                    return "初始化";
                default:
                    return "无此状态";
            }
        }else{
            return "未传入状态";
        }
    }
}
